<%@page pageEncoding="UTF-8" %><?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<%
org.sysmo.server.SysmoServer server = (org.sysmo.server.SysmoServer)application.getAttribute("sysmoServer");
org.sysmo.server.node.item.Item currentItem = server.getItem(Integer.parseInt(request.getParameter("iid")));
%>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/reset.css" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/main.css" />
    <!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="css/main-msie.css" /><![endif]-->
    <link rel="stylesheet" media="screen,projection" type="text/css" href="css/style.css" />
    <%--<link rel="stylesheet" media="print" type="text/css" href="css/print.css" />--%>

    <title><%= currentItem.getName() %> - sysmo</title>
    <script type="text/javascript" src="js/util.js" ></script>
    <script type="text/javascript">
        <!--

        function deleteGraph(id, name) {
            if (confirm("确实要删除图表项 " + name + " 吗？")) {
                window.location = "DeleteGraph.do?gid=" + id;
            }
        }

        function newGraph() {
            var name;
            do {
                name = prompt("新图表名", "");
                if (name == null) {
                    break;
                }
                if (name != "") {
                    window.location = "NewGraph.do?iid=<%= currentItem.getID() %>&name=" + UrlEncode(name);
                } else {
                    alert("请输入图表名");
                }
            } while (name == "");
        }

        <%
        if (request.getAttribute("error") != null) {
        %>
            alert("<%= org.sysmo.server.util.UtilHelper.encodeJSString((String)request.getAttribute("error")) %>");
        <%
        }
        %>
        -->
    </script>
</head>

<body>

<div id="main">

    <!-- Header -->
    <div id="header">
    
        <p id="logo">sysmo</p>
        
        <div id="slogan">A distributed system monitor tool</div>
    
    </div> <!-- /header -->
    
    <hr class="noscreen" />
    
    <!-- Navigation -->
    <div id="nav" class="box">
    
        <ul>
            <li class=""><a href="AllNodes.do">监控列表</a></li>
            <li class=""><a href="NewNodes.do">新增客户端</a></li>
            <li class=""><a href="Node.do?nid=<%= currentItem.getParentID() %>">返回所属节点</a></li>
            <li class="active"><a href="Item.do?iid=<%= currentItem.getID() %>">监控项(<%= currentItem.getName() %>)</a></li>
            <li class=""><a href="Users.do">用户管理</a></li>
            <li class=""><a href="Logout.do">退出登录(<%= ((org.sysmo.server.user.User)session.getAttribute("user")).getName() %>)</a></li>
        </ul>
    
    </div> <!-- /nav -->
    
    <hr class="noscreen" />
    
    <!-- Columns -->
    <div id="cols">
        <div id="cols-in" class="box">
    
            <!-- Content -->
            <div id="content">
                
                <h2 class="title-01"><%= currentItem.getName() %></h2>
                
                <div class="in">
                
                    <!-- Topstory -->
                    <div class="box">
                        <div id="topstory-txt">
                            <p><a href="javascript:newGraph()">增加新图表</a></p>
                            <table class="main_table">
                            <%
                            java.util.List<org.sysmo.server.node.item.graphgroup.GraphGroup> graphs = currentItem.getAllGraphes();
                            for (org.sysmo.server.node.item.graphgroup.GraphGroup graph : graphs) {
                            %>
                                <tr>
                                    <td class="graph_title"><a name="g<%= graph.getID() %>"></a><a href="Graph.do?gid=<%= graph.getID() %>"><%= graph.getName() %></a></td>
                                    <td>
                                        <a href="EditGraph.do?gid=<%= graph.getID() %>">编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                        <a href="javascript:deleteGraph(<%= graph.getID() %>, '<%= org.sysmo.server.util.UtilHelper.encodeJSString(graph.getName()) %>')">删除</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                        <a href="#top">返回导航</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                        <a href="CustomGraph.do?gid=<%= graph.getID() %>">自定义时间段显示</a>
                                    </td>
                                </tr>
                                <tr><%
                                long now = new java.util.Date().getTime();
                                long first = now - 24 * 60 * 60 * 1000;
                                %>
                                    <td colspan="2"><a href="Graph.do?gid=<%= graph.getID() %>"><img src="GetGraph.do?gid=<%= graph.getID() %>&g=<%= org.sysmo.server.node.item.graphgroup.GraphGroup.GType.G_BY_SECOND.ordinal() %>&start=<%= first %>&end=<%= now %>" class="graph_img" /></a></td>
                                </tr>
                            <%
                            }
                            %>
                            </table>
                            <p>所有图表数：<%= graphs.size() %></p>
                        </div> <!-- /topstory-txt -->
                        
                    </div> <!-- /box -->

                    <a name="warning"></a>
                    <h4 class="title-02"><span>此监控项警告（单击警告信息以删除）</span></h4>

                    <div class="box">
                        <table class="main_table">
                            <thead>
                                <th>警告信息</th>
                                <th>节点</th>
                                <th>监控项</th>
                                <th>图表</th>
                                <th>监控值</th>
                                <th>警告时间</th>
                            </thead>
                            <%
                            java.util.List<org.sysmo.server.node.item.Warning> warnings = currentItem.getAllWarnings();
                            java.text.SimpleDateFormat fmt = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
                            for (org.sysmo.server.node.item.Warning warning : warnings) {
                            %>
                            <tr>
                                <td><a href="DeleteWarning.do?re=2&reid=<%= currentItem.getID() %>&wid=<%= warning.getID() %>"><%= warning.getMessage() %></a></td>
                                <td><%
                                try {
                                    org.sysmo.server.node.AddedNode node = server.getNode(warning.getNodeID());
                                    out.print("<a href=\"Node.do?nid=" + node.getID() + "\">" + node.getName() + "</a>");
                                } catch (org.sysmo.server.node.NodeNotExistsException e) {
                                    out.print("未知节点");
                                }
                                %></td>
                                <td><%
                                try {
                                    org.sysmo.server.node.item.Item item = server.getItem(warning.getItemID());
                                    out.print("<a href=\"Item.do?iid=" + item.getID() + "\">" + item.getName() + "</a>");
                                } catch (org.sysmo.server.node.item.ItemNotExistsException e) {
                                    out.print("未知监控项");
                                }
                                %></td>
                                <td><%
                                try {
                                    org.sysmo.server.node.item.graphgroup.GraphGroup graph = server.getGraphGroup(warning.getGraphID());
                                    out.print("<a href=\"EditGraph.do?gid=" + graph.getID() + "\">" + graph.getName() + "</a>");
                                } catch (org.sysmo.server.node.item.graphgroup.GraphGroupNotExistsException e) {
                                    out.print("未知图表");
                                }
                                %></td>
                                <td><%
                                try {
                                    org.sysmo.server.node.item.graphgroup.value.Value value = server.getValue(warning.getValueID());
                                    out.print("<a href=\"EditGraph.do?gid=" + value.getParentID() + "\">" + value.getName() + "</a>");
                                } catch (org.sysmo.server.node.item.graphgroup.value.ValueNotExistsException e) {
                                    out.print("未知监控值");
                                }
                                %></td>
                                <td><%= fmt.format(warning.getTime()) %></td>
                            </tr>
                            <%
                            }
                            %>
                        </table>
                    </div>

                </div> <!-- /in -->
                
            </div> <!-- /content -->

            <hr class="noscreen" />

            <!-- Aside -->
            <div id="aside">
                <a name="top"></a>
                <h4 class="title-03">图表导航</h4>
                
                <div class="in">
                    <ul id="subnav">
                        <% for (org.sysmo.server.node.item.graphgroup.GraphGroup graph : graphs) { %>
                        <li><a href="#g<%= graph.getID() %>"><%= graph.getName() %></a></li>
                        <% } %>
                        <li><a href="#warning">此监控项警告</a></li>
                    </ul>

                </div> <!-- /in -->

            </div> <!-- /aside -->
            
        </div> <!-- /cols-in -->
    </div> <!-- /cols -->

    <hr class="noscreen" />
    
    <!-- Footer -->
    <div id="footer" class="box">
        
        <p class="f-left"><a href="http://sysmo.googlecode.com">sysmo @ GoogleCode</a></p>

    </div> <!-- /box -->

</div> <!-- /main -->

<!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php -->
<p id="copy"><a href="http://www.nuviotemplates.com/">Free web templates</a> presented by <a href="http://www.qartin.cz/">QARTIN</a> &ndash; Our tip: <a href="http://www.thinline.cz/">Webdesign</a>, <a href="http://www.cesky-hosting.cz/">Webhosting</a></p>
<!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php -->

</body>
</html>
